package com.cn.service.VipcustomerService;

import com.cn.Mapper.vipMapper.VipcustomerMapper;
import com.cn.entity.vip.Vipcustomer;
import com.cn.entity.vip.Vipcustomer_Search;
import com.cn.util.SqlsesstionUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName VipService
 * @Description TODO
 * @Author yujiajing
 * @Date 2022/10/12 10:35
 * @Version 1.0
 */
@Service
public class VipService {
    /**
     * 展示所有vip客户信息
     */
    public void showVip() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        vipcustomerMapper.selectVipcustomer();
    }

    /**
     * 类型：vip客户信息的删除服务
     */

    public void delete_vip(String vip_id) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        vipcustomerMapper.deleteVipcoustomer(vip_id);
    }

    /**
     * 申请VIP客户服务
     */
    public void register(Vipcustomer vipcustomer) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        vipcustomerMapper.insertVipcustomer(vipcustomer);

    }

    /**
     * 更新vip客户的电话
     */
    public void updateVipForMobilephone(String vip_id) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);

    }

    /**
     * 更新vip的积分信息
     */
    public void updateVipForPoint(String vip_point) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
    }

    /**
     * 搜索vip的信息（根据卡号索引）
     */
    public void SearchvipByCartId(String vip_CardId) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        //清空搜索表
        vipcustomerMapper.emptyVip_Search();
        //插入搜索信息
        vipcustomerMapper.insertVipByIdCard(vip_CardId);
        //显示搜索信息


/*        return vipcustomerMapper.showSearch();*/
    }

    /**
     * 校验vip，从而产生vip消费数据
     */
    public Vipcustomer loginVipByCardId(String Card_id) {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        return
                vipcustomerMapper.loginByCartId(Card_id);

    }
}